package com.xbongbong.pro.enums.permission.enums;

import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;
import lombok.ToString;

import java.util.Objects;

/**
 * @author long.rao
 * @version v1.0
 * @date 2020/4/7 13:48
 * @since v1.0
 */
@Getter
@ToString
public enum HandoverPermissionAliasEnum {
    CUSTOMER_HANDOVER(ProPermissionAliasEnum.CUSTOMER_HANDOVER.getAlias(), XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), ProPermissionAliasEnum.CUSTOMER_HANDOVER.getMemo()),
    OPPORTUNITY_HANDOVER(ProPermissionAliasEnum.OPPORTUNITY_HANDOVER.getAlias(), XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), ProPermissionAliasEnum.OPPORTUNITY_HANDOVER.getMemo()),
    REFUND_HANDOVER(ProPermissionAliasEnum.REFUND_HANDOVER.getAlias(), XbbRefTypeEnum.REFUND.getCode(), ProPermissionAliasEnum.REFUND_HANDOVER.getMemo()),
    CONTRACT_HANDOVER(ProPermissionAliasEnum.CONTRACT_HANDOVER.getAlias(), XbbRefTypeEnum.CONTRACT.getCode(), ProPermissionAliasEnum.CONTRACT_HANDOVER.getMemo()),
    QUOTATION_HANDOVER(ProPermissionAliasEnum.QUOTATION_HANDOVER.getAlias(), XbbRefTypeEnum.QUOTATION.getCode(), ProPermissionAliasEnum.QUOTATION_HANDOVER.getMemo()),
    SUPPLIER_HANDOVER(ProPermissionAliasEnum.SUPPLIER_HANDOVER.getAlias(), XbbRefTypeEnum.SUPPLIER.getCode(), ProPermissionAliasEnum.SUPPLIER_HANDOVER.getMemo()),
    PURCHASE_HANDOVER(ProPermissionAliasEnum.PURCHASE_HANDOVER.getAlias(), XbbRefTypeEnum.PURCHASE.getCode(), ProPermissionAliasEnum.PURCHASE_HANDOVER.getMemo()),
    BOMBILL_HANDOVER(ProPermissionAliasEnum.BOMBILL_HANDOVER.getAlias(), XbbRefTypeEnum.BOM_BILL.getCode(), ProPermissionAliasEnum.BOMBILL_HANDOVER.getMemo()),
    PRODUCTION_ORDER_HANDOVER(ProPermissionAliasEnum.PRODUCTION_ORDER_HANDOVER.getAlias(), XbbRefTypeEnum.PRODUCTION_ORDER.getCode(), ProPermissionAliasEnum.PRODUCTION_ORDER_HANDOVER.getMemo()),
    RETURNED_PURCHASE_HANDOVER(ProPermissionAliasEnum.RETURNED_PURCHASE_HANDOVER.getAlias(),XbbRefTypeEnum.RETURNED_PURCHASE.getCode(), ProPermissionAliasEnum.RETURNED_PURCHASE_HANDOVER.getMemo()),
    ASSEMBLE_HANDOVER(ProPermissionAliasEnum.ASSEMBLE_HANDOVER.getAlias(), XbbRefTypeEnum.ASSEMBLE.getCode(), ProPermissionAliasEnum.ASSEMBLE_HANDOVER.getMemo()),
    INSTOCK_HANDOVER(ProPermissionAliasEnum.INSTOCK_HANDOVER.getAlias(),XbbRefTypeEnum.OTHER_INSTOCK.getCode(), ProPermissionAliasEnum.INSTOCK_HANDOVER.getMemo()),
    PURCHASE_INSTOCK_HANDOVER(ProPermissionAliasEnum.PURCHASE_INSTOCK_HANDOVER.getAlias(), XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(), ProPermissionAliasEnum.PURCHASE_INSTOCK_HANDOVER.getMemo()),
    REFUND_INSTOCK_HANDOVER(ProPermissionAliasEnum.REFUND_INSTOCK_HANDOVER.getAlias(), XbbRefTypeEnum.REFUND_INSTOCK.getCode(), ProPermissionAliasEnum.REFUND_INSTOCK_HANDOVER.getMemo()),
    PRODUCTION_INSTOCK_HANDOVER(ProPermissionAliasEnum.PRODUCTION_INSTOCK_HANDOVER.getAlias(), XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(), ProPermissionAliasEnum.PRODUCTION_INSTOCK_HANDOVER.getMemo()),
    RETURNED_MATERIEL_INSTOCK_HANDOVER(ProPermissionAliasEnum.RETURNED_MATERIEL_INSTOCK_HANDOVER.getAlias(), XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(), ProPermissionAliasEnum.RETURNED_MATERIEL_INSTOCK_HANDOVER.getMemo()),

    OUTSTOCK_HANDOVER(ProPermissionAliasEnum.OUTSTOCK_HANDOVER.getAlias(), XbbRefTypeEnum.OTHER_OUTSTOCK.getCode(), ProPermissionAliasEnum.OUTSTOCK_HANDOVER.getMemo()),
    CONTRACT_OUTSTOCK_HANDOVER(ProPermissionAliasEnum.CONTRACT_OUTSTOCK_HANDOVER.getAlias(), XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(), ProPermissionAliasEnum.CONTRACT_OUTSTOCK_HANDOVER.getMemo()),
    RETURNED_PURCHASE_OUTSTOCK_HANDOVER(ProPermissionAliasEnum.RETURNED_PURCHASE_OUTSTOCK_HANDOVER.getAlias(), XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(), ProPermissionAliasEnum.RETURNED_PURCHASE_OUTSTOCK_HANDOVER.getMemo()),
    PRODUCTION_MATERIEL_OUTSTOCK_HANDOVER(ProPermissionAliasEnum.PRODUCTION_MATERIEL_OUTSTOCK_HANDOVER.getAlias(), XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(), ProPermissionAliasEnum.PRODUCTION_MATERIEL_OUTSTOCK_HANDOVER.getMemo()),
    WORK_ORDER_OUTSTOCK_HANDOVER(ProPermissionAliasEnum.WORK_ORDER_OUTSTOCK_HANDOVER.getAlias(), XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode(), ProPermissionAliasEnum.WORK_ORDER_OUTSTOCK_HANDOVER.getMemo()),


    TRANSFER_HANDOVER(ProPermissionAliasEnum.TRANSFER_HANDOVER.getAlias(), XbbRefTypeEnum.TRANSFER.getCode(), ProPermissionAliasEnum.TRANSFER_HANDOVER.getMemo()),
    INVENTORY_HANDOVER(ProPermissionAliasEnum.INVENTORY_HANDOVER.getAlias(), XbbRefTypeEnum.INVENTORY.getCode(), ProPermissionAliasEnum.INVENTORY_HANDOVER.getMemo()),

    CLUE_HANDOVER(ProPermissionAliasEnum.CLUE_HANDOVER.getAlias(), XbbRefTypeEnum.CLUE.getCode(), ProPermissionAliasEnum.CLUE_HANDOVER.getMemo()),
    MARKET_ACTIVITY_HANDOVER(ProPermissionAliasEnum.MARKET_ACTIVITY_HANDOVER.getAlias(), XbbRefTypeEnum.MARKET_ACTIVITY.getCode(), ProPermissionAliasEnum.MARKET_ACTIVITY_HANDOVER.getMemo()),
    WAREHOUSE_HANDOVER(ProPermissionAliasEnum.WAREHOUSE_HANDOVER.getAlias(),XbbRefTypeEnum.WAREHOUSE.getCode(), ProPermissionAliasEnum.WAREHOUSE_HANDOVER.getMemo()),
    /**
     * 联系人移交
     */
    CONTACT_HANDOVER(ProPermissionAliasEnum.CONTACT_HANDOVER.getAlias(),XbbRefTypeEnum.CONTACT.getCode(), ProPermissionAliasEnum.CONTACT_HANDOVER.getMemo()),
    /**
     * 应收款移交
     */
    PAYMENT_HANDOVER(ProPermissionAliasEnum.PAYMENT_HANDOVER.getAlias(),XbbRefTypeEnum.PAYMENT.getCode(), ProPermissionAliasEnum.PAYMENT_HANDOVER.getMemo()),
    /**
     * 回款单移交
     */
    PAYMENT_SHEET_HANDOVER(ProPermissionAliasEnum.PAYMENT_SHEET_HANDOVER.getAlias(),XbbRefTypeEnum.PAYMENT_SHEET.getCode(), ProPermissionAliasEnum.PAYMENT_SHEET_HANDOVER.getMemo()),
    /**
     * 付款计划移交
     */
    PAY_PLAN_HANDOVER(ProPermissionAliasEnum.PAY_PLAN_HANDOVER.getAlias(),XbbRefTypeEnum.PAY_PLAN.getCode(), ProPermissionAliasEnum.PAY_PLAN_HANDOVER.getMemo()),
    /**
     * 付款单移交
     */
    PAY_SHEET_HANDOVER(ProPermissionAliasEnum.PAY_SHEET_HANDOVER.getAlias(),XbbRefTypeEnum.PAY_SHEET.getCode(), ProPermissionAliasEnum.PAY_SHEET_HANDOVER.getMemo()),
    /**
     * 付款单移交
     */
    SUPPLIER_CONTACT_HANDOVER(ProPermissionAliasEnum.SUPPLIER_CONTACT_HANDOVER.getAlias(),XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(), ProPermissionAliasEnum.SUPPLIER_CONTACT_HANDOVER.getMemo()),
    /**
     * 工单v2移交
     */
    WORK_ORDER_V2_HANDOVER(ProPermissionAliasEnum.WORK_ORDER_V2_HANDOVER.getAlias(),XbbRefTypeEnum.WORK_ORDER_V2.getCode(), ProPermissionAliasEnum.WORK_ORDER_V2_HANDOVER.getMemo()),

    /**
     * 回执单移交
     */
    RECEIPT_ORDER_HANDOVER(ProPermissionAliasEnum.RECEIPT_ORDER_HANDOVER.getAlias(),XbbRefTypeEnum.RECEIPT_ORDER.getCode(), ProPermissionAliasEnum.RECEIPT_ORDER_HANDOVER.getMemo()),

    UNKNOWN(ProPermissionAliasEnum.UNKNOWN.getAlias(), XbbRefTypeEnum.UNKNOWN.getCode(), ProPermissionAliasEnum.UNKNOWN.getMemo()),
    ;

    private String alias;

    private Integer businessType;

    private String memo;

    HandoverPermissionAliasEnum(String alias, Integer businessType, String memo) {
        this.alias = alias;
        this.businessType = businessType;
        this.memo = memo;
    }

    public static HandoverPermissionAliasEnum getByCode(Integer businessType) {
        for (HandoverPermissionAliasEnum item: values()) {
            if (Objects.equals(item.getBusinessType(), businessType)) {
                return item;
            }
        }
        return UNKNOWN;
    }
}
